import { ReqPage, ResPage } from '@/api/interface'
import { TBY } from '@/api/config/servicePort'
import http from '@/api'

export namespace WildCameraAttach {
  /**查询参数 */
  export interface Query extends ReqPage {
    speciesId?: number
    speciesCode?: string
    cameraId?: number
    fileType?: string
    shotDateBegin?: string
    shotDateEnd?: string
    shotDate?: string
  }

  /**列表内容 */
  export interface Record {
    id: number
    cameraId: number
    cameraName: string
    speciesId: number
    speciesName: string
    speciesCode: string
    fileType: string
    filePath: string
    shotDate: string
    shotDateFormat: string
  }
}

// 分页查询
export const pageWildCameraAttach = (params: WildCameraAttach.Query) => {
  return http.get<ResPage<WildCameraAttach.Record>>(TBY + `/wild_camera_attach/page`, params)
}

// 删除
export const removeWildCameraAttach = (id: number) => {
  return http.delete(TBY + `/wild_camera_attach/delete`, { id })
}

// 详情信息
export const getWildCameraAttachDetail = (id: number) => {
  return http.get<Partial<WildCameraAttach.Record>>(TBY + `/wild_camera_attach/get`, { id }, { loading: false })
}

export const updateSpeciesCode = (id: number, speciesCode: string, speciesName: string) => {
  return http.post(TBY + `/wild_camera_attach/update_species_code`, {
    id: id,
    speciesCode: speciesCode,
    speciesName: speciesName
  })
}
